﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using System.Reflection;
using System.Windows.Media.Imaging;
using System.Windows;
using Autodesk.Revit.DB;

namespace spark
{
    //[Transaction(TransactionMode.Manual)]
    public class SparkApp : IExternalApplication
    {
        public Result OnShutdown(UIControlledApplication application)
        {
            
            return Result.Succeeded;
        }

        public Result OnStartup(UIControlledApplication application)
        {
            application.CreateRibbonTab("Spark");
            var panel01 = application.CreateRibbonPanel("Spark", "默认工具");
            string assemblyPath = Assembly.GetExecutingAssembly().Location;
            // MessageBox.Show(assemblyPath);  // spark.dll
            string className = "spark.RunApp";
            var runBtnData = new PushButtonData("Spark", "运行", assemblyPath, className);
            PushButton runBtn = panel01.AddItem(runBtnData) as PushButton;
            runBtn.LargeImage = new BitmapImage(new Uri(@"C:\Users\Lin Haojie\source\repos\spark\Resources\run@64.png", UriKind.Absolute));
            runBtn.ToolTip = "打开程序界面";
            return Result.Succeeded;
        }
    }
}
